// const modelsUser = require('../models/user.js');
const QRCode = require('qrcode');
const controllersQRcode = {
    async static(req, res) {
        const { text, options } = req.body;
        if (!text) {
            return res.send({
                code: -1,
                msg: '无效链接',
            });
        }
        const qrOptions = {
            type: 'image/png',
            width: 180,
            margin: 0,
            scale: 1,
            color: {
                dark: '#000000',
                light: '#ffffff'
            },
            errorCorrectionLevel: 'M',
            quality: 1
        }
        Object.assign(qrOptions, options);
        const result = await QRCode.toDataURL(text, qrOptions);
        res.send({
            code: 0,
            msg: 'success',
            data: result
        });
    }
};
module.exports = controllersQRcode;